package lovo01.game;

/**
 * 裁判类
 */
public class Judge {
    private Player player = new Player();
    private Computer computer = new Computer();

    public Judge(Player player,Computer computer){
        this.player = player;
        this.computer = computer;
    }
    /**
     *判断玩家输赢的情况
     */

    public void check(){
        int number1 = player.input();
        int number2 = computer.guess();
        if (number2 == 0){
            System.out.println("电脑给的剪刀");
        }
        if (number2 == 1){
            System.out.println("电脑给的石头");
        }
        if (number2 == 2){
            System.out.println("电脑给的布");
        }

        if (number1 - number2 == -1 || number1 - number2 == -2){
            System.out.println("玩家胜利");
            player.setScore(player.getScore() + 1);
        }else if(number1 == number2){
            System.out.println("平局");
        }else{
            System.out.println("电脑胜利");
            computer.setScore(computer.getScore() + 1);
        }
    }

    /**
     * 总分比较
     */
    public void totalScore(){
        if (player.getScore() > computer.getScore()){
            System.out.println("玩家胜利");
        }else if(player.getScore() < computer.getScore()){
            System.out.println("电脑胜利");
        }else{
            System.out.println("平局");
        }
    }
}